package cn.edu.zzuli.common.exception;


import cn.edu.zzuli.common.result.Result;
import cn.edu.zzuli.common.result.ResultInfo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {

    private Result result;

    @ExceptionHandler(Exception.class)
    public ResultInfo error(Exception e){
        e.printStackTrace();
        return result.fail(e.getMessage());
    }

    @ExceptionHandler(CustomException.class)
    public ResultInfo error(CustomException e){
        System.out.println(e.getMessage());
        return result.fail(e.getMessage());
    }
}
